﻿using Microsoft.Extensions.Configuration;
using System.IO;

namespace HCMS.Utils
{
    /// <summary>
    /// 配置文件 工具类
    /// </summary>
    public class ConfigUtil
    {
        private readonly static IConfigurationRoot _config;

        static ConfigUtil()
        {
            _config = new ConfigurationBuilder()
                    .SetBasePath(Directory.GetCurrentDirectory())
                    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                    .Build();
        }

        /// <summary>
        /// 获取节点配置信息
        /// </summary>
        /// <param name="node">配置节点</param>
        /// <returns></returns>
        public static string GetValue(string node)
        {
            return _config[node] ?? "";
        }
    }
}
